<?php

/*

COMP 353F
Dr. B Desai
Final Project
Group #11

6330746 Nicholas CONSTANTINIDIS
9532862 Jacqueline FU
5484537 Claudio Javier LOPEZ FLORES
9218416 Que Tung NGUYEN

*/

  session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
        <title>CoBAGSys - Home</title>
        <link type="text/css" rel="stylesheet" href="css/mystyle.css">
</head>
<body>
    <?php
      require 'menus.php';
    ?>
    <?php
		function removePosting() {
			$db = new Connect();
			
			// TODO: Use the real table name and columns
			$sql = "UPDATE table_for_postings " .
				   "SET status = 'removed' " .
				   "WHERE pid = " . $_GET['pid'];
				   
			$result = $db->query($sql);
			
			if(!$result || mysql_num_rows($result) == 0) // Couldn't remove posting
			{
				return false;
			}
			else // Posting removed
			{
				return true;
			}
		}
		
		$removesuccess = false;
		if (isset($_GET['pid']))
			$removesuccess = removePosting();
    ?>
    <div id="main">
		<p class="title">
			Remove posting
		</p>
<?php
	if ($removesuccess)
	{
		print "<p class=\"normal\">The posting has been removed.</p>";
	}
	else
	{
		print "<p></p><span class=\"error\">INVALID POSTING SPECIFIED!</span>";
	}
?>
    </div>
</body>
</html>
